const path = require("path")
    //将传入的相对路径转换为绝对路径
function resolve(dir) {
    return path.join(__dirname, dir)
}
module.exports = {
    publicPath: process.env.NODE_ENV === "production" ? "./" : "/",

    configureWebpack: {
        devServer: {
            port: 8080,
            open: true
        }
    },
    lintOnSave: false,
    chainWebpack(config) {
        config.module.rule('svg')
            .exclude.add(resolve('src/icons'));
        //添加svg-sprite-loader
        config.module.rule('icons')
            .test(/\.svg$/)
            .include.add(resolve('src/icons'))
            .end()
            .use('svg-sprite-loader')
            .loader('svg-sprite-loader')
            .options({ symbolId: 'icon-[name]' })
            .end()
    },
}